#include <bits/stdc++.h>
using namespace std;

int main() {
  int T;
  cin >> T;
  for (int i = 1; i <= T; i++) {
    int n;
    cin >> n;
    vector<int> b(n + 1);
    for (int j = 1; j <= n; j++) {
      cin >> b[j];
    }
    long long A = 0, B = 0;
    for (int j = 1; j <= n; j++) {
      if (b[j] > 0) {
        A = A + j;
      } else {
        B = B + j;
      }
    }
    cout << abs(A - B) << endl;
  }

  return 0;
}